package part2;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * Main2Read
 *  - Read an entire object from a file
 * @author tony
 *
 */

public class Main2ReadObject {
	public static void main(String[] args) {
		final String INPUTFILENAME = "output.obj";
		Data d2 = null;
		System.out.println( "In this program we will read an object from the file " + INPUTFILENAME );
		try {
			FileInputStream fi = new FileInputStream( INPUTFILENAME );
			ObjectInputStream ois = new ObjectInputStream( fi );
			d2 = (Data) ois.readObject();
			ois.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		System.out.println( "   OK, done reading. We read in " + d2 );
	}
}
